package thread;

public class Demo7 {
    public static void main(String[] args) {
        Thread t = new Thread(()-> {
           while(!Thread.currentThread().isInterrupted()) {
               System.out.println("提醒线程要终止!");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
                   //e.printStackTrace();
               }
           }
        });

        t.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        t.interrupt();
    }
}
